package com.cirnoworks.common;

import com.cirnoworks.guice.LifeCycle;

public abstract class LifeCycledThread implements LifeCycle, Runnable {

	private Thread runner;

	public void interrupt() {
		runner.interrupt();
	}

	public boolean isInterrupted() {
		return runner.isInterrupted();
	}

	@Override
	public void startup() {
		if (runner == null) {
			runner = new Thread(this);
			runner.start();
		} else {
			throw new IllegalStateException();
		}
	}

	@Override
	public void shutdown() {
		runner.interrupt();
	}

}
